'use strict';
const db = uniCloud.database();
exports.main = async (event, context) => {
	//event为客户端上传的参数
	let status=2;
	let res_msg="";
	let body=event.body
	let body_json=JSON.parse(body)
	let manager_name=body_json.manager_name
	let password=body_json.password
	const collection = db.collection('Manager');
	const check_manager_name= await collection.where({"manager_name": manager_name}).get();
	if(check_manager_name.data.length==0){
		status=1;
		res_msg="管理员名不存在";
	}else{
		if(password!=check_manager_name.data[0].password){
			status=0;
			res_msg="密码错误";
		}else{
			res_msg=check_manager_name.data[0];
		}
		
	}
	//返回数据给客户端
	return {"status":status,"res_msg":res_msg}

};